<?php
/**
* Application boot sequence.
* This is executed immediately after the "config.php" script and it's job is to
* trigger the bootstrap script for the site being requested.
*
* @package Scribble
* @subpackage SkeletonApp
*/
use Buan\Config;
use Buan\ExtensionManager;

// Register Twig autoloader.
// This is only needed if you're planning to use the Twig templating library and
// is only here to demonstrate how you can use libraries other than PHP to
// render templates.
// If you don't intend to use Twig, remove or comment out this lines.
require_once(dirname(__FILE__).'/lib/Twig/Autoloader.php');
Twig_Autoloader::register();

// Register the Scribble extension and find a suitable site-specific configuration
ExtensionManager::register(Config::get('app.docRoot').'/scribble-cms/Scribble.php');
$scribble = ExtensionManager::get('Scribble');
$site = $scribble->findSiteConfiguration(array(

	/* The default configuration, used when no other matches are found */
	'__default__'=>array(
		'bootstrap'=>dirname(__FILE__).'/default-bootstrap.php'
	)
));

// Bootstrap the site
if($site===NULL) {
	die("Cannot find a matching site configuration for the requested resource.");
}
else {
	include_once($site['bootstrap']);
}
?>